package com.yiren.dbaa.util;

import com.yiren.backstage.currency.utils.StringUtil;

import java.math.BigDecimal;

/**
 * Created by WANGRONGXIANG
 * on 2022/3/9
 * Describe 距离转换工具类
 */
public class MeterTransferUtil {

    /**
     * @param distance
     * @return
     */
    public static String parse2English(float distance) {
        if (distance < 0) {
            distance = 0;
        }
        if (distance <= 999) {
            return StringUtil.format(distance, "#") + "M";
        } else {
            return StringUtil.format((distance / 1000), "#.##") + "KM";
        }
    }

    /**
     * @param distance （米）
     * @return 253674189E9  2536741899
     */
    public static String parse2Chinese(float distance) {
        if (distance < 0) {
            distance = 0;
        }
        if (distance <= 999) {
            return StringUtil.format(distance, "#") + "米";
        } else {
            return StringUtil.format((distance / 1000), "#.##") + "公里";
        }
    }

    /**
     * 格式化角度
     *
     * @param degree
     * @return
     */
    public static String formatDegree(float degree) {
        return StringUtil.format(degree, "#.#") + "度";
    }
}
